package rawengine.util;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;



public final class Conversion2D {

	
	private static final int SIZE_FLOAT = 4;
	private static final int SIZE_INT = 4;
	
	
	
	public static float convert(String lin)
	{
		return Float.parseFloat(lin);
	}
	
	public static float[] convertK4(String[] lin)
	{
		float f[] = {Float.parseFloat(lin[0]), Float.parseFloat(lin[1]), Float.parseFloat(lin[2]), 0.0f};
		return f;
	}
	
	public static float[] convertK3(String[] lin)
	{
		float f[] = {Float.parseFloat(lin[0]), Float.parseFloat(lin[1]), 
					 Float.parseFloat(lin[2])};
		return f;
	}
	

	
	public static FloatBuffer allocFloats(float[] floatarray) 
	{
		FloatBuffer fb = ByteBuffer.allocateDirect(floatarray.length * SIZE_FLOAT).order(
				ByteOrder.nativeOrder()).asFloatBuffer();
		fb.put(floatarray).flip();
		return fb;
	}
	
	public static IntBuffer allocInts(int[] intarray) 
	{
		IntBuffer ib = ByteBuffer.allocateDirect(intarray.length * SIZE_INT).order(
				ByteOrder.nativeOrder()).asIntBuffer();
		ib.put(intarray).flip();
		return ib;
	}
	
	/* File browsing utilities methods.
	 */

	
	
}
